// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <PySaveWindowAttributes.h>
#include <ObserverToCallback.h>
#include <stdio.h>
#include <Py2and3Support.h>
#include <PySaveSubWindowsAttributes.h>
#include <PyDBOptionsAttributes.h>

// ****************************************************************************
// Module: PySaveWindowAttributes
//
// Purpose:
//   This class contains the attributes used for saving windows.
//
// Note:       Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation:   omitted
//
// ****************************************************************************

//
// This struct contains the Python type information and a SaveWindowAttributes.
//
struct SaveWindowAttributesObject
{
    PyObject_HEAD
    SaveWindowAttributes *data;
    bool        owns;
    PyObject   *parent;
};

//
// Internal prototypes
//
static PyObject *NewSaveWindowAttributes(int);
std::string
PySaveWindowAttributes_ToString(const SaveWindowAttributes *atts, const char *prefix, const bool forLogging)
{
    std::string str;
    char tmpStr[1000];

    if(atts->GetOutputToCurrentDirectory())
        snprintf(tmpStr, 1000, "%soutputToCurrentDirectory = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%soutputToCurrentDirectory = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%soutputDirectory = \"%s\"\n", prefix, atts->GetOutputDirectory().c_str());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sfileName = \"%s\"\n", prefix, atts->GetFileName().c_str());
    str += tmpStr;
    if(atts->GetFamily())
        snprintf(tmpStr, 1000, "%sfamily = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sfamily = 0\n", prefix);
    str += tmpStr;
    const char *format_names = "BMP, CURVE, JPEG, OBJ, PNG, "
        "POSTSCRIPT, POVRAY, PPM, RGB, "
        "STL, TIFF, ULTRA, VTK, "
        "PLY, EXR";
    switch (atts->GetFormat())
    {
      case SaveWindowAttributes::BMP:
          snprintf(tmpStr, 1000, "%sformat = %sBMP  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::CURVE:
          snprintf(tmpStr, 1000, "%sformat = %sCURVE  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::JPEG:
          snprintf(tmpStr, 1000, "%sformat = %sJPEG  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::OBJ:
          snprintf(tmpStr, 1000, "%sformat = %sOBJ  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::PNG:
          snprintf(tmpStr, 1000, "%sformat = %sPNG  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::POSTSCRIPT:
          snprintf(tmpStr, 1000, "%sformat = %sPOSTSCRIPT  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::POVRAY:
          snprintf(tmpStr, 1000, "%sformat = %sPOVRAY  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::PPM:
          snprintf(tmpStr, 1000, "%sformat = %sPPM  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::RGB:
          snprintf(tmpStr, 1000, "%sformat = %sRGB  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::STL:
          snprintf(tmpStr, 1000, "%sformat = %sSTL  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::TIFF:
          snprintf(tmpStr, 1000, "%sformat = %sTIFF  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::ULTRA:
          snprintf(tmpStr, 1000, "%sformat = %sULTRA  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::VTK:
          snprintf(tmpStr, 1000, "%sformat = %sVTK  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::PLY:
          snprintf(tmpStr, 1000, "%sformat = %sPLY  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::EXR:
          snprintf(tmpStr, 1000, "%sformat = %sEXR  # %s\n", prefix, prefix, format_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    snprintf(tmpStr, 1000, "%swidth = %d\n", prefix, atts->GetWidth());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sheight = %d\n", prefix, atts->GetHeight());
    str += tmpStr;
    if(atts->GetScreenCapture())
        snprintf(tmpStr, 1000, "%sscreenCapture = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sscreenCapture = 0\n", prefix);
    str += tmpStr;
    if(atts->GetSaveTiled())
        snprintf(tmpStr, 1000, "%ssaveTiled = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%ssaveTiled = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%squality = %d\n", prefix, atts->GetQuality());
    str += tmpStr;
    if(atts->GetProgressive())
        snprintf(tmpStr, 1000, "%sprogressive = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sprogressive = 0\n", prefix);
    str += tmpStr;
    if(atts->GetBinary())
        snprintf(tmpStr, 1000, "%sbinary = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sbinary = 0\n", prefix);
    str += tmpStr;
    if(atts->GetStereo())
        snprintf(tmpStr, 1000, "%sstereo = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sstereo = 0\n", prefix);
    str += tmpStr;
    const char *compression_names = "NONE, PackBits, Jpeg, Deflate, LZW";
    switch (atts->GetCompression())
    {
      case SaveWindowAttributes::None:
          snprintf(tmpStr, 1000, "%scompression = %sNONE  # %s\n", prefix, prefix, compression_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::PackBits:
          snprintf(tmpStr, 1000, "%scompression = %sPackBits  # %s\n", prefix, prefix, compression_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::Jpeg:
          snprintf(tmpStr, 1000, "%scompression = %sJpeg  # %s\n", prefix, prefix, compression_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::Deflate:
          snprintf(tmpStr, 1000, "%scompression = %sDeflate  # %s\n", prefix, prefix, compression_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::LZW:
          snprintf(tmpStr, 1000, "%scompression = %sLZW  # %s\n", prefix, prefix, compression_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    if(atts->GetForceMerge())
        snprintf(tmpStr, 1000, "%sforceMerge = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sforceMerge = 0\n", prefix);
    str += tmpStr;
    const char *resConstraint_names = "NoConstraint, EqualWidthHeight, ScreenProportions";
    switch (atts->GetResConstraint())
    {
      case SaveWindowAttributes::NoConstraint:
          snprintf(tmpStr, 1000, "%sresConstraint = %sNoConstraint  # %s\n", prefix, prefix, resConstraint_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::EqualWidthHeight:
          snprintf(tmpStr, 1000, "%sresConstraint = %sEqualWidthHeight  # %s\n", prefix, prefix, resConstraint_names);
          str += tmpStr;
          break;
      case SaveWindowAttributes::ScreenProportions:
          snprintf(tmpStr, 1000, "%sresConstraint = %sScreenProportions  # %s\n", prefix, prefix, resConstraint_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    snprintf(tmpStr, 1000, "%spixelData = %d\n", prefix, atts->GetPixelData());
    str += tmpStr;
    if(atts->GetAdvancedMultiWindowSave())
        snprintf(tmpStr, 1000, "%sadvancedMultiWindowSave = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sadvancedMultiWindowSave = 0\n", prefix);
    str += tmpStr;
    { // new scope
        std::string objPrefix(prefix);
        objPrefix += "subWindowAtts.";
        str += PySaveSubWindowsAttributes_ToString(&atts->GetSubWindowAtts(), objPrefix.c_str(), forLogging);
    }
    { // new scope
        std::string objPrefix(prefix);
        objPrefix += "opts.";
        str += PyDBOptionsAttributes_ToString(&atts->GetOpts(), objPrefix.c_str(), forLogging);
    }
    return str;
}

static PyObject *
SaveWindowAttributes_Notify(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    obj->data->Notify();
    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_SetOutputToCurrentDirectory(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the outputToCurrentDirectory in the object.
    obj->data->SetOutputToCurrentDirectory(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetOutputToCurrentDirectory(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetOutputToCurrentDirectory()?1L:0L);
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetOutputDirectory(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the outputDirectory in the object.
    obj->data->SetOutputDirectory(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetOutputDirectory(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyString_FromString(obj->data->GetOutputDirectory().c_str());
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetFileName(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the fileName in the object.
    obj->data->SetFileName(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetFileName(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyString_FromString(obj->data->GetFileName().c_str());
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetFamily(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the family in the object.
    obj->data->SetFamily(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetFamily(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetFamily()?1L:0L);
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetFormat(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 15)
    {
        std::stringstream ss;
        ss << "An invalid format value was given." << std::endl;
        ss << "Valid values are in the range [0,14]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " BMP";
        ss << ", CURVE";
        ss << ", JPEG";
        ss << ", OBJ";
        ss << ", PNG";
        ss << ", POSTSCRIPT";
        ss << ", POVRAY";
        ss << ", PPM";
        ss << ", RGB";
        ss << ", STL";
        ss << ", TIFF";
        ss << ", ULTRA";
        ss << ", VTK";
        ss << ", PLY";
        ss << ", EXR";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the format in the object.
    obj->data->SetFormat(SaveWindowAttributes::FileFormat(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetFormat(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetFormat()));
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetWidth(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the width in the object.
    obj->data->SetWidth(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetWidth(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetWidth()));
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetHeight(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the height in the object.
    obj->data->SetHeight(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetHeight(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetHeight()));
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetScreenCapture(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the screenCapture in the object.
    obj->data->SetScreenCapture(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetScreenCapture(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetScreenCapture()?1L:0L);
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetSaveTiled(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the saveTiled in the object.
    obj->data->SetSaveTiled(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetSaveTiled(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetSaveTiled()?1L:0L);
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetQuality(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the quality in the object.
    obj->data->SetQuality(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetQuality(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetQuality()));
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetProgressive(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the progressive in the object.
    obj->data->SetProgressive(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetProgressive(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetProgressive()?1L:0L);
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetBinary(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the binary in the object.
    obj->data->SetBinary(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetBinary(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetBinary()?1L:0L);
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetStereo(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the stereo in the object.
    obj->data->SetStereo(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetStereo(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetStereo()?1L:0L);
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetCompression(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 5)
    {
        std::stringstream ss;
        ss << "An invalid compression value was given." << std::endl;
        ss << "Valid values are in the range [0,4]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " None";
        ss << ", PackBits";
        ss << ", Jpeg";
        ss << ", Deflate";
        ss << ", LZW";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the compression in the object.
    obj->data->SetCompression(SaveWindowAttributes::CompressionType(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetCompression(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetCompression()));
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetForceMerge(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the forceMerge in the object.
    obj->data->SetForceMerge(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetForceMerge(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetForceMerge()?1L:0L);
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetResConstraint(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 3)
    {
        std::stringstream ss;
        ss << "An invalid resConstraint value was given." << std::endl;
        ss << "Valid values are in the range [0,2]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " NoConstraint";
        ss << ", EqualWidthHeight";
        ss << ", ScreenProportions";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the resConstraint in the object.
    obj->data->SetResConstraint(SaveWindowAttributes::ResConstraint(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetResConstraint(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetResConstraint()));
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetPixelData(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the pixelData in the object.
    obj->data->SetPixelData(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetPixelData(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetPixelData()));
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetAdvancedMultiWindowSave(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the advancedMultiWindowSave in the object.
    obj->data->SetAdvancedMultiWindowSave(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetAdvancedMultiWindowSave(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetAdvancedMultiWindowSave()?1L:0L);
    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetSubWindowAtts(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *newValue = NULL;
    if(!PyArg_ParseTuple(args, "O", &newValue))
        return NULL;
    if(!PySaveSubWindowsAttributes_Check(newValue))
        return PyErr_Format(PyExc_TypeError, "Field subWindowAtts can be set only with SaveSubWindowsAttributes objects");

    obj->data->SetSubWindowAtts(*PySaveSubWindowsAttributes_FromPyObject(newValue));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetSubWindowAtts(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    // Since the new object will point to data owned by this object,
    // we need to increment the reference count.
    Py_INCREF(self);

    PyObject *retval = PySaveSubWindowsAttributes_Wrap(&obj->data->GetSubWindowAtts());
    // Set the object's parent so the reference to the parent can be decref'd
    // when the child goes out of scope.
    PySaveSubWindowsAttributes_SetParent(retval, self);

    return retval;
}

/*static*/ PyObject *
SaveWindowAttributes_SetOpts(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;

    PyObject *newValue = NULL;
    if(!PyArg_ParseTuple(args, "O", &newValue))
        return NULL;
    if(!PyDBOptionsAttributes_Check(newValue))
        return PyErr_Format(PyExc_TypeError, "Field opts can be set only with DBOptionsAttributes objects");

    obj->data->SetOpts(*PyDBOptionsAttributes_FromPyObject(newValue));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SaveWindowAttributes_GetOpts(PyObject *self, PyObject *args)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)self;
    // Since the new object will point to data owned by this object,
    // we need to increment the reference count.
    Py_INCREF(self);

    PyObject *retval = PyDBOptionsAttributes_Wrap(&obj->data->GetOpts());
    // Set the object's parent so the reference to the parent can be decref'd
    // when the child goes out of scope.
    PyDBOptionsAttributes_SetParent(retval, self);

    return retval;
}



PyMethodDef PySaveWindowAttributes_methods[SAVEWINDOWATTRIBUTES_NMETH] = {
    {"Notify", SaveWindowAttributes_Notify, METH_VARARGS},
    {"SetOutputToCurrentDirectory", SaveWindowAttributes_SetOutputToCurrentDirectory, METH_VARARGS},
    {"GetOutputToCurrentDirectory", SaveWindowAttributes_GetOutputToCurrentDirectory, METH_VARARGS},
    {"SetOutputDirectory", SaveWindowAttributes_SetOutputDirectory, METH_VARARGS},
    {"GetOutputDirectory", SaveWindowAttributes_GetOutputDirectory, METH_VARARGS},
    {"SetFileName", SaveWindowAttributes_SetFileName, METH_VARARGS},
    {"GetFileName", SaveWindowAttributes_GetFileName, METH_VARARGS},
    {"SetFamily", SaveWindowAttributes_SetFamily, METH_VARARGS},
    {"GetFamily", SaveWindowAttributes_GetFamily, METH_VARARGS},
    {"SetFormat", SaveWindowAttributes_SetFormat, METH_VARARGS},
    {"GetFormat", SaveWindowAttributes_GetFormat, METH_VARARGS},
    {"SetWidth", SaveWindowAttributes_SetWidth, METH_VARARGS},
    {"GetWidth", SaveWindowAttributes_GetWidth, METH_VARARGS},
    {"SetHeight", SaveWindowAttributes_SetHeight, METH_VARARGS},
    {"GetHeight", SaveWindowAttributes_GetHeight, METH_VARARGS},
    {"SetScreenCapture", SaveWindowAttributes_SetScreenCapture, METH_VARARGS},
    {"GetScreenCapture", SaveWindowAttributes_GetScreenCapture, METH_VARARGS},
    {"SetSaveTiled", SaveWindowAttributes_SetSaveTiled, METH_VARARGS},
    {"GetSaveTiled", SaveWindowAttributes_GetSaveTiled, METH_VARARGS},
    {"SetQuality", SaveWindowAttributes_SetQuality, METH_VARARGS},
    {"GetQuality", SaveWindowAttributes_GetQuality, METH_VARARGS},
    {"SetProgressive", SaveWindowAttributes_SetProgressive, METH_VARARGS},
    {"GetProgressive", SaveWindowAttributes_GetProgressive, METH_VARARGS},
    {"SetBinary", SaveWindowAttributes_SetBinary, METH_VARARGS},
    {"GetBinary", SaveWindowAttributes_GetBinary, METH_VARARGS},
    {"SetStereo", SaveWindowAttributes_SetStereo, METH_VARARGS},
    {"GetStereo", SaveWindowAttributes_GetStereo, METH_VARARGS},
    {"SetCompression", SaveWindowAttributes_SetCompression, METH_VARARGS},
    {"GetCompression", SaveWindowAttributes_GetCompression, METH_VARARGS},
    {"SetForceMerge", SaveWindowAttributes_SetForceMerge, METH_VARARGS},
    {"GetForceMerge", SaveWindowAttributes_GetForceMerge, METH_VARARGS},
    {"SetResConstraint", SaveWindowAttributes_SetResConstraint, METH_VARARGS},
    {"GetResConstraint", SaveWindowAttributes_GetResConstraint, METH_VARARGS},
    {"SetPixelData", SaveWindowAttributes_SetPixelData, METH_VARARGS},
    {"GetPixelData", SaveWindowAttributes_GetPixelData, METH_VARARGS},
    {"SetAdvancedMultiWindowSave", SaveWindowAttributes_SetAdvancedMultiWindowSave, METH_VARARGS},
    {"GetAdvancedMultiWindowSave", SaveWindowAttributes_GetAdvancedMultiWindowSave, METH_VARARGS},
    {"SetSubWindowAtts", SaveWindowAttributes_SetSubWindowAtts, METH_VARARGS},
    {"GetSubWindowAtts", SaveWindowAttributes_GetSubWindowAtts, METH_VARARGS},
    {"SetOpts", SaveWindowAttributes_SetOpts, METH_VARARGS},
    {"GetOpts", SaveWindowAttributes_GetOpts, METH_VARARGS},
    {NULL, NULL}
};

//
// Type functions
//

static void
SaveWindowAttributes_dealloc(PyObject *v)
{
   SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)v;
   if(obj->parent != 0)
       Py_DECREF(obj->parent);
   if(obj->owns)
       delete obj->data;
}

static PyObject *SaveWindowAttributes_richcompare(PyObject *self, PyObject *other, int op);
PyObject *
PySaveWindowAttributes_getattr(PyObject *self, char *name)
{
    if(strcmp(name, "outputToCurrentDirectory") == 0)
        return SaveWindowAttributes_GetOutputToCurrentDirectory(self, NULL);
    if(strcmp(name, "outputDirectory") == 0)
        return SaveWindowAttributes_GetOutputDirectory(self, NULL);
    if(strcmp(name, "fileName") == 0)
        return SaveWindowAttributes_GetFileName(self, NULL);
    if(strcmp(name, "family") == 0)
        return SaveWindowAttributes_GetFamily(self, NULL);
    if(strcmp(name, "format") == 0)
        return SaveWindowAttributes_GetFormat(self, NULL);
    if(strcmp(name, "BMP") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::BMP));
    if(strcmp(name, "CURVE") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::CURVE));
    if(strcmp(name, "JPEG") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::JPEG));
    if(strcmp(name, "OBJ") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::OBJ));
    if(strcmp(name, "PNG") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::PNG));
    if(strcmp(name, "POSTSCRIPT") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::POSTSCRIPT));
    if(strcmp(name, "POVRAY") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::POVRAY));
    if(strcmp(name, "PPM") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::PPM));
    if(strcmp(name, "RGB") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::RGB));
    if(strcmp(name, "STL") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::STL));
    if(strcmp(name, "TIFF") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::TIFF));
    if(strcmp(name, "ULTRA") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::ULTRA));
    if(strcmp(name, "VTK") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::VTK));
    if(strcmp(name, "PLY") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::PLY));
    if(strcmp(name, "EXR") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::EXR));

    if(strcmp(name, "width") == 0)
        return SaveWindowAttributes_GetWidth(self, NULL);
    if(strcmp(name, "height") == 0)
        return SaveWindowAttributes_GetHeight(self, NULL);
    if(strcmp(name, "screenCapture") == 0)
        return SaveWindowAttributes_GetScreenCapture(self, NULL);
    if(strcmp(name, "saveTiled") == 0)
        return SaveWindowAttributes_GetSaveTiled(self, NULL);
    if(strcmp(name, "quality") == 0)
        return SaveWindowAttributes_GetQuality(self, NULL);
    if(strcmp(name, "progressive") == 0)
        return SaveWindowAttributes_GetProgressive(self, NULL);
    if(strcmp(name, "binary") == 0)
        return SaveWindowAttributes_GetBinary(self, NULL);
    if(strcmp(name, "stereo") == 0)
        return SaveWindowAttributes_GetStereo(self, NULL);
    if(strcmp(name, "compression") == 0)
        return SaveWindowAttributes_GetCompression(self, NULL);
    if(strcmp(name, "None") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::None));
    if(strcmp(name, "NONE") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::None));
    if(strcmp(name, "PackBits") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::PackBits));
    if(strcmp(name, "Jpeg") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::Jpeg));
    if(strcmp(name, "Deflate") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::Deflate));
    if(strcmp(name, "LZW") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::LZW));

    if(strcmp(name, "forceMerge") == 0)
        return SaveWindowAttributes_GetForceMerge(self, NULL);
    if(strcmp(name, "resConstraint") == 0)
        return SaveWindowAttributes_GetResConstraint(self, NULL);
    if(strcmp(name, "NoConstraint") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::NoConstraint));
    if(strcmp(name, "EqualWidthHeight") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::EqualWidthHeight));
    if(strcmp(name, "ScreenProportions") == 0)
        return PyInt_FromLong(long(SaveWindowAttributes::ScreenProportions));

    if(strcmp(name, "pixelData") == 0)
        return SaveWindowAttributes_GetPixelData(self, NULL);
    if(strcmp(name, "advancedMultiWindowSave") == 0)
        return SaveWindowAttributes_GetAdvancedMultiWindowSave(self, NULL);
    if(strcmp(name, "subWindowAtts") == 0)
        return SaveWindowAttributes_GetSubWindowAtts(self, NULL);
    if(strcmp(name, "opts") == 0)
        return SaveWindowAttributes_GetOpts(self, NULL);


    // Add a __dict__ answer so that dir() works
    if (!strcmp(name, "__dict__"))
    {
        PyObject *result = PyDict_New();
        for (int i = 0; PySaveWindowAttributes_methods[i].ml_meth; i++)
            PyDict_SetItem(result,
                PyString_FromString(PySaveWindowAttributes_methods[i].ml_name),
                PyString_FromString(PySaveWindowAttributes_methods[i].ml_name));
        return result;
    }

    return Py_FindMethod(PySaveWindowAttributes_methods, self, name);
}

int
PySaveWindowAttributes_setattr(PyObject *self, char *name, PyObject *args)
{
    PyObject NULL_PY_OBJ;
    PyObject *obj = &NULL_PY_OBJ;

    if(strcmp(name, "outputToCurrentDirectory") == 0)
        obj = SaveWindowAttributes_SetOutputToCurrentDirectory(self, args);
    else if(strcmp(name, "outputDirectory") == 0)
        obj = SaveWindowAttributes_SetOutputDirectory(self, args);
    else if(strcmp(name, "fileName") == 0)
        obj = SaveWindowAttributes_SetFileName(self, args);
    else if(strcmp(name, "family") == 0)
        obj = SaveWindowAttributes_SetFamily(self, args);
    else if(strcmp(name, "format") == 0)
        obj = SaveWindowAttributes_SetFormat(self, args);
    else if(strcmp(name, "width") == 0)
        obj = SaveWindowAttributes_SetWidth(self, args);
    else if(strcmp(name, "height") == 0)
        obj = SaveWindowAttributes_SetHeight(self, args);
    else if(strcmp(name, "screenCapture") == 0)
        obj = SaveWindowAttributes_SetScreenCapture(self, args);
    else if(strcmp(name, "saveTiled") == 0)
        obj = SaveWindowAttributes_SetSaveTiled(self, args);
    else if(strcmp(name, "quality") == 0)
        obj = SaveWindowAttributes_SetQuality(self, args);
    else if(strcmp(name, "progressive") == 0)
        obj = SaveWindowAttributes_SetProgressive(self, args);
    else if(strcmp(name, "binary") == 0)
        obj = SaveWindowAttributes_SetBinary(self, args);
    else if(strcmp(name, "stereo") == 0)
        obj = SaveWindowAttributes_SetStereo(self, args);
    else if(strcmp(name, "compression") == 0)
        obj = SaveWindowAttributes_SetCompression(self, args);
    else if(strcmp(name, "forceMerge") == 0)
        obj = SaveWindowAttributes_SetForceMerge(self, args);
    else if(strcmp(name, "resConstraint") == 0)
        obj = SaveWindowAttributes_SetResConstraint(self, args);
    else if(strcmp(name, "pixelData") == 0)
        obj = SaveWindowAttributes_SetPixelData(self, args);
    else if(strcmp(name, "advancedMultiWindowSave") == 0)
        obj = SaveWindowAttributes_SetAdvancedMultiWindowSave(self, args);
    else if(strcmp(name, "subWindowAtts") == 0)
        obj = SaveWindowAttributes_SetSubWindowAtts(self, args);
    else if(strcmp(name, "opts") == 0)
        obj = SaveWindowAttributes_SetOpts(self, args);

    if (obj != NULL && obj != &NULL_PY_OBJ)
        Py_DECREF(obj);

    if (obj == &NULL_PY_OBJ)
    {
        obj = NULL;
        PyErr_Format(PyExc_NameError, "name '%s' is not defined", name);
    }
    else if (obj == NULL && !PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "unknown problem with '%s'", name);

    return (obj != NULL) ? 0 : -1;
}

static int
SaveWindowAttributes_print(PyObject *v, FILE *fp, int flags)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)v;
    fprintf(fp, "%s", PySaveWindowAttributes_ToString(obj->data, "",false).c_str());
    return 0;
}

PyObject *
SaveWindowAttributes_str(PyObject *v)
{
    SaveWindowAttributesObject *obj = (SaveWindowAttributesObject *)v;
    return PyString_FromString(PySaveWindowAttributes_ToString(obj->data,"", false).c_str());
}

//
// The doc string for the class.
//
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5)
static const char *SaveWindowAttributes_Purpose = "This class contains the attributes used for saving windows.";
#else
static char *SaveWindowAttributes_Purpose = "This class contains the attributes used for saving windows.";
#endif

//
// Python Type Struct Def Macro from Py2and3Support.h
//
//         VISIT_PY_TYPE_OBJ( VPY_TYPE,
//                            VPY_NAME,
//                            VPY_OBJECT,
//                            VPY_DEALLOC,
//                            VPY_PRINT,
//                            VPY_GETATTR,
//                            VPY_SETATTR,
//                            VPY_STR,
//                            VPY_PURPOSE,
//                            VPY_RICHCOMP,
//                            VPY_AS_NUMBER)

//
// The type description structure
//

VISIT_PY_TYPE_OBJ(SaveWindowAttributesType,         \
                  "SaveWindowAttributes",           \
                  SaveWindowAttributesObject,       \
                  SaveWindowAttributes_dealloc,     \
                  SaveWindowAttributes_print,       \
                  PySaveWindowAttributes_getattr,   \
                  PySaveWindowAttributes_setattr,   \
                  SaveWindowAttributes_str,         \
                  SaveWindowAttributes_Purpose,     \
                  SaveWindowAttributes_richcompare, \
                  0); /* as_number*/

//
// Helper function for comparing.
//
static PyObject *
SaveWindowAttributes_richcompare(PyObject *self, PyObject *other, int op)
{
    // only compare against the same type 
    if ( Py_TYPE(self) != &SaveWindowAttributesType
         || Py_TYPE(other) != &SaveWindowAttributesType)
    {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    PyObject *res = NULL;
    SaveWindowAttributes *a = ((SaveWindowAttributesObject *)self)->data;
    SaveWindowAttributes *b = ((SaveWindowAttributesObject *)other)->data;

    switch (op)
    {
       case Py_EQ:
           res = (*a == *b) ? Py_True : Py_False;
           break;
       case Py_NE:
           res = (*a != *b) ? Py_True : Py_False;
           break;
       default:
           res = Py_NotImplemented;
           break;
    }

    Py_INCREF(res);
    return res;
}

//
// Helper functions for object allocation.
//

static SaveWindowAttributes *defaultAtts = 0;
static SaveWindowAttributes *currentAtts = 0;

static PyObject *
NewSaveWindowAttributes(int useCurrent)
{
    SaveWindowAttributesObject *newObject;
    newObject = PyObject_NEW(SaveWindowAttributesObject, &SaveWindowAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new SaveWindowAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new SaveWindowAttributes(*defaultAtts);
    else
        newObject->data = new SaveWindowAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

static PyObject *
WrapSaveWindowAttributes(const SaveWindowAttributes *attr)
{
    SaveWindowAttributesObject *newObject;
    newObject = PyObject_NEW(SaveWindowAttributesObject, &SaveWindowAttributesType);
    if(newObject == NULL)
        return NULL;
    newObject->data = (SaveWindowAttributes *)attr;
    newObject->owns = false;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

///////////////////////////////////////////////////////////////////////////////
//
// Interface that is exposed to the VisIt module.
//
///////////////////////////////////////////////////////////////////////////////

PyObject *
SaveWindowAttributes_new(PyObject *self, PyObject *args)
{
    int useCurrent = 0;
    if (!PyArg_ParseTuple(args, "i", &useCurrent))
    {
        if (!PyArg_ParseTuple(args, ""))
            return NULL;
        else
            PyErr_Clear();
    }

    return (PyObject *)NewSaveWindowAttributes(useCurrent);
}

//
// Plugin method table. These methods are added to the visitmodule's methods.
//
static PyMethodDef SaveWindowAttributesMethods[] = {
    {"SaveWindowAttributes", SaveWindowAttributes_new, METH_VARARGS},
    {NULL,      NULL}        /* Sentinel */
};

static Observer *SaveWindowAttributesObserver = 0;

std::string
PySaveWindowAttributes_GetLogString()
{
    std::string s("SaveWindowAtts = SaveWindowAttributes()\n");
    if(currentAtts != 0)
        s += PySaveWindowAttributes_ToString(currentAtts, "SaveWindowAtts.", true);
    return s;
}

static void
PySaveWindowAttributes_CallLogRoutine(Subject *subj, void *data)
{
    typedef void (*logCallback)(const std::string &);
    logCallback cb = (logCallback)data;

    if(cb != 0)
    {
        std::string s("SaveWindowAtts = SaveWindowAttributes()\n");
        s += PySaveWindowAttributes_ToString(currentAtts, "SaveWindowAtts.", true);
        cb(s);
    }
}

void
PySaveWindowAttributes_StartUp(SaveWindowAttributes *subj, void *data)
{
    if(subj == 0)
        return;

    currentAtts = subj;
    PySaveWindowAttributes_SetDefaults(subj);

    //
    // Create the observer that will be notified when the attributes change.
    //
    if(SaveWindowAttributesObserver == 0)
    {
        SaveWindowAttributesObserver = new ObserverToCallback(subj,
            PySaveWindowAttributes_CallLogRoutine, (void *)data);
    }

}

void
PySaveWindowAttributes_CloseDown()
{
    delete defaultAtts;
    defaultAtts = 0;
    delete SaveWindowAttributesObserver;
    SaveWindowAttributesObserver = 0;
}

PyMethodDef *
PySaveWindowAttributes_GetMethodTable(int *nMethods)
{
    *nMethods = 1;
    return SaveWindowAttributesMethods;
}

bool
PySaveWindowAttributes_Check(PyObject *obj)
{
    return (obj->ob_type == &SaveWindowAttributesType);
}

SaveWindowAttributes *
PySaveWindowAttributes_FromPyObject(PyObject *obj)
{
    SaveWindowAttributesObject *obj2 = (SaveWindowAttributesObject *)obj;
    return obj2->data;
}

PyObject *
PySaveWindowAttributes_New()
{
    return NewSaveWindowAttributes(0);
}

PyObject *
PySaveWindowAttributes_Wrap(const SaveWindowAttributes *attr)
{
    return WrapSaveWindowAttributes(attr);
}

void
PySaveWindowAttributes_SetParent(PyObject *obj, PyObject *parent)
{
    SaveWindowAttributesObject *obj2 = (SaveWindowAttributesObject *)obj;
    obj2->parent = parent;
}

void
PySaveWindowAttributes_SetDefaults(const SaveWindowAttributes *atts)
{
    if(defaultAtts)
        delete defaultAtts;

    defaultAtts = new SaveWindowAttributes(*atts);
}

